% Function:
%   plot vertical line for specified x
% Argument:
%   x: specified x value
%   s: line specific
% Return:
%   ln: Line handle
function ln = vline(x, s)
    % check arguments
    if nargin == 1
        s = 'k--';
    end

    % plot without cleaning
    hold on;

    % if x is column vector, transform it to row vector
    if iscolumn(x)
        x = x';
    end

    x = repmat(x, 2, 1);
    y = ylim;

    ln = plot(x, y, s);


    for i = 1 : numel(ln)
        ln(i).ButtonDownFcn = @linecallback;
    end
end

% Local functions
function linecallback(ln, ~)
    delete(ln);
end
